package com.unicorn.base;

import com.unicorn.util.common.BaseComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

/**
 * Created by user on 2016/12/3.
 */
public class PlatformListenner extends BaseComponent implements ApplicationListener<ContextRefreshedEvent> {



    @Autowired
    protected ApplicationContext context;

    protected Properties props;


    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        systemInit();
        System.out.println("listenner"+contextRefreshedEvent.getTimestamp());

    }


    protected  void systemInit(){

        File sysRoot=new File(VinaceConfig.ONLINE_FILE_SYSTEM_ROOT);
        File userRoot=new File(VinaceConfig.PLATFORM_USER_DOC_ROOT);
        if(!sysRoot.exists()){
            sysRoot.mkdirs();
        }
        if(!userRoot.exists()){
            userRoot.mkdirs();
        }

    }
}
